package cn.kgc.mes.storage.service.impl;

import java.util.List;
import cn.kgc.mes.common.utils.DateUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.kgc.mes.storage.mapper.MaterialStockMapper;
import cn.kgc.mes.storage.domain.MaterialStock;
import cn.kgc.mes.storage.service.IMaterialStockService;

/**
 * 库存现有量Service业务层处理
 * 
 * @author ydw
 * @date 2025-09-11
 */
@Service
public class MaterialStockServiceImpl extends ServiceImpl<MaterialStockMapper, MaterialStock> implements IMaterialStockService
{
    @Autowired
    private MaterialStockMapper materialStockMapper;

    /**
     * 查询库存现有量
     * 
     * @param materialStockId 库存现有量主键
     * @return 库存现有量
     */
    @Override
    public MaterialStock selectMaterialStockByMaterialStockId(Long materialStockId)
    {
        return materialStockMapper.selectMaterialStockByMaterialStockId(materialStockId);
    }

    /**
     * 查询库存现有量列表
     * 
     * @param materialStock 库存现有量
     * @return 库存现有量
     */
    @Override
    public List<MaterialStock> selectMaterialStockList(MaterialStock materialStock)
    {
        return materialStockMapper.selectMaterialStockList(materialStock);
    }

    /**
     * 新增库存现有量
     * 
     * @param materialStock 库存现有量
     * @return 结果
     */
    @Override
    public int insertMaterialStock(MaterialStock materialStock)
    {
        materialStock.setCreateTime(DateUtils.getNowDate());
        return materialStockMapper.insertMaterialStock(materialStock);
    }

    /**
     * 修改库存现有量
     * 
     * @param materialStock 库存现有量
     * @return 结果
     */
    @Override
    public int updateMaterialStock(MaterialStock materialStock)
    {
        materialStock.setUpdateTime(DateUtils.getNowDate());
        return materialStockMapper.updateMaterialStock(materialStock);
    }

    /**
     * 批量删除库存现有量
     * 
     * @param materialStockIds 需要删除的库存现有量主键
     * @return 结果
     */
    @Override
    public int deleteMaterialStockByMaterialStockIds(Long[] materialStockIds)
    {
        return materialStockMapper.deleteMaterialStockByMaterialStockIds(materialStockIds);
    }

    /**
     * 删除库存现有量信息
     * 
     * @param materialStockId 库存现有量主键
     * @return 结果
     */
    @Override
    public int deleteMaterialStockByMaterialStockId(Long materialStockId)
    {
        return materialStockMapper.deleteMaterialStockByMaterialStockId(materialStockId);

    }
    //根据itemId删除库存现有量
    public int deleteMaterialStockByItemId(Long itemId){
        return materialStockMapper.deleteMaterialStockByItemId(itemId);
    }
}
